Skip to content

feat(generated): Add new event types and user object to membership models#642

Open
workos-sdk-automation[bot] wants to merge 1 commit intomainfrom
oagen/spec-update-91fc76ae21e088f16365ddfab59bf9c29940d135
Open

feat(generated): Add new event types and user object to membership models#642
workos-sdk-automation[bot] wants to merge 1 commit intomainfrom
oagen/spec-update-91fc76ae21e088f16365ddfab59bf9c29940d135

Conversation

@workos-sdk-automation
Copy link
Copy Markdown
Contributor

Summary

  • New Event Classes: Added DsyncTokenCreated, DsyncTokenCreatedData, DsyncTokenDeleted, and DsyncTokenDeletedData classes for directory sync token lifecycle events
  • New Membership Model: Added UserOrganizationMembershipBaseWithUser class (renamed from internal UserOrganizationMembershipBaseListData in authorization) that includes nested user object
  • New User Fields: Added name field to DirectoryUser, DsyncUserUpdatedData, DirectoryUserWithGroups, and Profile models for full user name
  • Enhanced Organization Membership: Added user field to OrganizationMembership to include user object in membership responses
  • New Type Aliases: Added ApiKeyValidationResponseApiKey and ApiKeyValidationResponseApiKeyOwner type aliases for API key validation responses
  • New Enum Value: Added ADMIN_PORTAL to EventContextActorSource enum for admin portal event source tracking
  • Relocated Model: Moved UserOrganizationMembershipBaseListData from authorization to groups module for better code organization

Triggered by workos/openapi-spec@91fc76a

@workos-sdk-automation workos-sdk-automation Bot requested a review from a team as a code owner April 30, 2026 20:02
@workos-sdk-automation workos-sdk-automation Bot added the autogenerated Autogenerated code or content label Apr 30, 2026
@workos-sdk-automation workos-sdk-automation Bot requested a review from a team as a code owner April 30, 2026 20:02
@workos-sdk-automation workos-sdk-automation Bot added the autogenerated Autogenerated code or content label Apr 30, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 30, 2026

Greptile Summary

This auto-generated PR adds new dsync.token.created/dsync.token.deleted event types, a new UserOrganizationMembershipBaseWithUser model with a nested user object, a name field across several user-related models, and relocates UserOrganizationMembershipBaseListData from authorization/models to groups/models.

  • P1: UserOrganizationMembershipBaseListData is deleted from workos.authorization.models with no re-export shim — any existing consumer importing from that path will get an ImportError at runtime.
  • P1: OrganizationMembership.user is added as a required (non-optional, no default) field; deserialization of any pre-existing response JSON without user will raise a KeyError.

Confidence Score: 3/5

Two P1 breaking changes need review before merging: a removed public import path and a new required field that will fail deserialization of older responses.

Two independent P1 findings — a hard import break and a deserialization break — lower the score below the P1 ceiling of 4. The rest of the additions (new event types, optional name fields, type aliases) are clean and well-tested.

src/workos/authorization/models/init.py (removed export) and src/workos/user_management/models/organization_membership.py (required user field).

Important Files Changed

Filename Overview
src/workos/authorization/models/init.py Removes UserOrganizationMembershipBaseListData export and replaces it with UserOrganizationMembershipBaseWithUser — breaking import path change for existing consumers.
src/workos/user_management/models/organization_membership.py Adds required user: User field (no default) to OrganizationMembership; from_dict uses data["user"] which breaks deserialization of responses without this field.
src/workos/authorization/models/user_organization_membership_base_with_user.py New UserOrganizationMembershipBaseWithUser model with nested User object; well-structured with proper deserialization and serialization.
src/workos/common/models/dsync_token_created.py New DsyncTokenCreated event model; consistent with existing event model patterns.
src/workos/common/models/dsync_token_created_data.py New DsyncTokenCreatedData model; expires_at is required (uses data["expires_at"]) but nullable — correct handling via walrus operator pattern.
src/workos/events/models/event_schema.py Registers dsync.token.created and dsync.token.deleted event types in the schema dispatch map.
src/workos/groups/models/user_organization_membership_base_list_data.py File relocated from authorization/models/ to groups/models/ with no content changes.

Class Diagram

%%{init: {'theme': 'neutral'}}%%
classDiagram
    class OrganizationMembership {
        +str id
        +str user_id
        +str organization_id
        +OrganizationMembershipStatus status
        +bool directory_managed
        +SlimRole role
        +User user
        +Optional[str] organization_name
        +from_dict()
        +to_dict()
    }
    class UserOrganizationMembershipBaseWithUser {
        +str id
        +str user_id
        +str organization_id
        +UserOrganizationMembershipBaseWithUserStatus status
        +bool directory_managed
        +User user
        +Optional[str] organization_name
        +from_dict()
        +to_dict()
    }
    class UserOrganizationMembershipBaseListData {
        +str id
        +str user_id
        +str organization_id
        +UserOrganizationMembershipBaseListDataStatus status
        +bool directory_managed
        +from_dict()
        +to_dict()
    }
    class DsyncTokenCreated {
        +str id
        +Literal event
        +DsyncTokenCreatedData data
        +datetime created_at
        +from_dict()
        +to_dict()
    }
    class DsyncTokenCreatedData {
        +str id
        +str directory_id
        +str token_suffix
        +datetime created_at
        +Optional[datetime] expires_at
        +Optional[str] organization_id
        +from_dict()
        +to_dict()
    }
    class DsyncTokenDeleted {
        +str id
        +Literal event
        +DsyncTokenDeletedData data
        +from_dict()
        +to_dict()
    }
    note for UserOrganizationMembershipBaseListData "Moved: authorization/models to groups/models - No re-export from authorization"
    note for OrganizationMembership "Breaking: user field now required"
    DsyncTokenCreated --> DsyncTokenCreatedData
    DsyncTokenDeleted --> DsyncTokenCreatedData : TypeAlias
    OrganizationMembership --> User
    UserOrganizationMembershipBaseWithUser --> User
Loading

Reviews (1): Last reviewed commit: "feat(generated): Add new event types and..." | Re-trigger Greptile

Comment on lines 33 to 38
)
from .update_organization_role import UpdateOrganizationRole as UpdateOrganizationRole
from .update_role import UpdateRole as UpdateRole
from .user_organization_membership_base_list_data import (
UserOrganizationMembershipBaseListData as UserOrganizationMembershipBaseListData,
from .user_organization_membership_base_with_user import (
UserOrganizationMembershipBaseWithUser as UserOrganizationMembershipBaseWithUser,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Breaking removal of UserOrganizationMembershipBaseListData from authorization exports

UserOrganizationMembershipBaseListData has been entirely removed from workos.authorization.models and the underlying file deleted from the authorization/models/ directory. Any existing consumer that imports this class from its documented location (from workos.authorization.models import UserOrganizationMembershipBaseListData) will receive an ImportError after upgrading. The class is now only available from workos.groups.models.

Without a re-export shim (e.g. from workos.groups.models import UserOrganizationMembershipBaseListData as UserOrganizationMembershipBaseListData in the old __init__.py) or a deprecation warning, this constitutes a hard breaking change. Consider whether a major version bump or a compatibility alias is needed.

Comment on lines +42 to +43
user: "User"
"""The user that belongs to the organization through this membership."""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 user is a required field with no default — hard-breaks deserialization of existing responses

user: "User" has no default value and from_dict accesses it via data["user"] (line 63). Any cached, logged, or replayed OrganizationMembership JSON that predates this API change will raise a KeyError (caught and re-raised as a deserialization error) at runtime. If the API does not guarantee this field on all endpoints that return OrganizationMembership (e.g. paginated lists that may omit nested objects), this will cause silent breakage in production.

If the field may legitimately be absent on some endpoints, it should be Optional["User"] = None to preserve backward compatibility. If the API always returns it, this is low-risk but the breaking deserialization behavior should be called out in release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autogenerated Autogenerated code or content

Development

Successfully merging this pull request may close these issues.

0 participants